import {mapGetters,mapState} from 'vuex'  
export default {
  computed:{
    ...mapGetters('m_cart',['total']),
    ...mapState('m_cart',['cart'])
  },
  onShow(){
    if(this.total > 0){
      this.setBadge()
    }else{
      this.hideBadge()
    }
  },
  methods:{
    setBadge(){
      uni.setTabBarBadge({
        index:2,
        text:this.cart.length + ''
      })
    },
    hideBadge(){
      uni.removeTabBarBadge({
        index: 2
      })
    }
  }
}